<template>
  <div style="overflow: auto; height: 100%; padding: 26px 36px">
    <div v-for="(group, index) in groups" :key="index">
      <div
        style="
          font-family: PingFangSC, PingFang SC;
          font-weight: 500;
          font-size: 18px;
          color: #333333;
          line-height: 25px;
          text-align: left;
          font-style: normal;
          margin-bottom: 20px;
        "
      >
        {{ group.name }}
      </div>
      <div style="display: flex; flex-wrap: wrap">
        <div
          v-for="flow in group.flows"
          :key="flow.FLOW_ID"
          style="
            display: flex;
            align-items: center;
            width: 244px;
            height: 90px;
            background: #f9f9f9;
            margin-right: 23px;
            padding: 22px;
            box-sizing: border-box;
            margin-bottom: 20px;
          "
        >
          <div
            style="
              width: 48px;
              height: 48px;
              border-radius: 5px;
              display: flex;
              align-items: center;
              justify-content: center;
              margin-right: 15px;
              cursor: pointer;
            "
            @click="toStartForm(flow.FLOW_ID)"
            :style="{ background: colors[index % 4] }"
          >
            <div
              style="
                font-family: AlimamaShuHeiTi, AlimamaShuHeiTi;
                font-weight: bold;
                font-size: 22px;
                color: #ffffff;
                line-height: 26px;
                text-align: left;
                font-style: normal;
              "
            >
              {{ flow.FLOW_Name.substring(0, 1) }}
            </div>
          </div>
          <div
            style="
              font-family: PingFangSC, PingFang SC;
              font-weight: 500;
              font-size: 12px;
              color: #333333;
              line-height: 22px;
              text-align: left;
              font-style: normal;
            "
          >
            {{ flow.FLOW_Name }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getFlowGroups } from '@/api/common/home'
export default {
  components: {},
  data: function () {
    return {
      groups: [],
      colors: ['#FF6C40', '#35C9B7', '#4089FF', '#00BF56'],
    }
  },
  methods: {
    getFlowGroups() {
      getFlowGroups().then(({ data }) => {
        this.groups = data
      })
    },
    toStartForm(flowId) {
      this.$router.push({
        name: 'formInfoPage',
        query: { flowId },
      })
    },
  },
  created: function () {
    this.getFlowGroups()
  },
}
</script>
<style scoped></style>
